<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php
/**
 * Template for Sf_AutoCoupon_View
*email 邮箱
*events_code  活动编码 
*rule_id  规则id
*/

//配置项
$coupon_url = $this->getBaseUrl()."autocoupon/new/sendEmailCoupon/";
$rule_id    = array('6','7','8');
?>
<!DOCTYPE html>

</head>
<body>
<div class="view">
	<div class="row">
	    <div class="col-sm-18">
	        <div class="em-wrapper-area03"><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('em0131-furniture-area-main01-home-new-arrivals-tab01')->toHtml();;?></div>
	    </div>
	    <div class="col-sm-6">
	        <div class="em-wrapper-area02"><?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('em0131-furniture-area-main01-home-new-arrivals-tab02')->toHtml();?></div>
	    </div>
	</div>
	<div class="_promote_views">
		<div class="vibeitest_promote" style="position: absolute;top:0;">
			<div>
				<span><img src="<?php echo $this->getSkinUrl('images/view/vibeitest_promote.png');?>" alt=""></span>
				<div><p >Получи купоны на 9$ на покупку на сайте <a href="<?php echo $this->getBaseUrl() ?>" > Rumall.com</a></p></div>
				<div class="vibeitest_promote_form">
					<form action="<?php echo $coupon_url ?>" method="post" id="vibeitest_promote">
						<div class="input-box">
							<input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" name="email" id="vibeitest_promote_email" title="<?php echo Mage::helper('core')->quoteEscape($this->__('ign up for Discounts')) ?>" class="input-text required-entry validate-email" />
							<input type="hidden" name="events_code" value="vibeitest_promote" />
						</div>
						<div class="actions">
							<button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Получить купон') ?></span></span></button>
						</div>
						<div class="input-boxs">
							<input type="checkbox" value="1" checked name='checkbox'> Я принимаю условия <a target="_Blank" href="<?php echo $this->getBaseUrl() ?>privacy-policy/"> Политики конфиденциальности </a> и <a target="_Blank" href="<?php echo $this->getBaseUrl() ?>terms-conditions/"> Условия Продажи </a> сайта Rumall.com
						</div>
						<div>
							<span id="vibeitest_promote_box" style="margin-left:5px;"></span>
						</div>
					</form>
				</div>
			</div>
			<div class="vibeitest_promote_obj" style="position: absolute;border: 2px solid #222222;border-radius: 20px;padding: 6px;top: 6px;right: 6px;"><img src="<?php echo $this->getSkinUrl('images/view/close_button.png');?>"/></div>
		</div>		
	</div>

</div>
<script type="text/javascript">
 //<![CDATA[
	(function($){	
		/*弹窗定位随窗口滚动显示不同*/
        var view_heg = $(".view").offset().top;
        $(window).scroll(function () {
            if ($(window).scrollTop() > view_heg -65) {
				$('.vibeitest_promote').css({"position":"fixed","top":"10rem"});
            }else{
				$('.vibeitest_promote').css({"position":"absolute","top":"0"});
            }
        });
		

		$('#vibeitest_promote').submit(function(){
			var email       = $("#vibeitest_promote_email").val();
			var events_code = $("#vibeitest_promote input[name=events_code]").val();
			var rule_id     = <?php echo json_encode($rule_id); ?>;
			var view_url    =  $("#vibeitest_promote").attr("action");
			if($('#vibeitest_promote input[name=checkbox]').is(':checked')) {
				if(email && events_code && rule_id ){
					$("#vibeitest_promote_box").html('<img src="<?php echo $this->getSkinUrl('images/ajax-review.jpg');?>">');
					$.post(view_url,{"email":email,events_code:events_code,rule_id:rule_id},function(data){
						if(data == 'success'){
			                var countdown = setInterval(CountDown, 1000);
			                $("#vibeitest_promote_box").css("color","#434343");
							$("#vibeitest_promote_box").html('Ура! Ваши купоны были отправлены на ваш email!');					
						}else{
			                $("#vibeitest_promote_box").css("color","#e33e3e");
							$("#vibeitest_promote_box").html('Приносим извинения, акция уже закончилась. Заходите на <a href="<?php echo $this->getBaseUrl() ?>" > Rumall.com</a>, тут всегда много интересного.');
						}
					},"json" );
				}
			}	

			var count = 5;
			function CountDown() {
				if (count < 1) {
					window.location.href = "<?php echo $this->getBaseUrl(); ?>";
					return;
				}
				count--;
				$("#vibeitest_promote_box span").html(count);
			}
			return false;
		})
		$('.vibeitest_promote_obj').click(function(){
			$('._promote_views').css("display","none");			
		})	
	})(jQuery);
//]]> 
</script>

</body>
</html>

	
